/*
 * Chain of Responsibility pattern avoids coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.
 * The pattern chains the receiving objects and passes the request along the chain until an object handles it. It has a behavioral purpose and deals with
 * relationships between objects.
 * 
 * more than one object may handle an request, and the handler should be ascertained automatically.
 * you want to issue a request to one of several objects without specifying the receiver explicitly.
 * the set of objects that can handle a request should be specified dynamically.
 */

#ifndef _CPP_DESIGN_PATTERN_CHAIN_OF_RESPONSITILIBITY_H
#define _CPP_DESIGN_PATTERN_CHAIN_OF_RESPONSITILIBITY_H

#include <iostream>

class Handler
{
public:
    virtual ~Handler() {}

    virtual void setHandler(Handler *);

    virtual void handleRequest();

private:
    Handler *successor_;
};

class ConcreteHandlerA : public Handler
{
public:
    ~ConcreteHandlerA() {}

    bool canHandle();

    virtual void handleRequest();
};

class ConcreteHandlerB : public Handler
{
public:
    ~ConcreteHandlerB() {}

    bool canHandle();

    virtual void handleRequest();
};

#endif